package cn.lili.controller.feign;

import cn.lili.modules.promotion.client.BlindboxRelClient;
import cn.lili.modules.promotion.entity.BlindboxRelVO;
import cn.lili.modules.promotion.entity.dos.BlindboxRuleOrder;
import cn.lili.modules.promotion.service.BlindboxRelService;
import cn.lili.modules.promotion.service.BlindboxRuleOrderService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author xiangqian
 * @Date 2023/10/6 14:58
 */
@RestController
@RequiredArgsConstructor
public class BlindboxRelFeignController implements BlindboxRelClient {

    private final BlindboxRelService blindboxRelService;

    private final BlindboxRuleOrderService blindboxRuleOrderService;
    /**
     * 添加盲盒规则商品关联
     * */
    @Override
    public Boolean addBlindboxRel(BlindboxRelVO blindboxRelVO) {
        return blindboxRelService.addBlindboxRel(blindboxRelVO);
    }

    @Override
    public List<BlindboxRuleOrder> getOrderByGoodsIds(String ids) {
        LambdaQueryWrapper<BlindboxRuleOrder> blindboxRuleOrderLambdaQueryWrapper = new LambdaQueryWrapper<>();
        blindboxRuleOrderLambdaQueryWrapper.in(BlindboxRuleOrder::getRuleGoodsId, (Object[]) ids.split(","));
        return blindboxRuleOrderService.list(blindboxRuleOrderLambdaQueryWrapper);
    }
}
